import request from '@/utils/request'
import {DataSourceAddDTO, DataSourceQuery, DataSourceUpdateDTO} from "@/api/data-source/models";

const commonUrl = '/sw/dataSource'

//添加数据源
export const addDataSourceApi = (data: DataSourceAddDTO) => {
    return request({
        url: `${commonUrl}/addDataSource`, // 假设创建模板的API路径
        method: 'post',
        data // 将数据传递到请求体中
    })
}

//更新数据源
export const updateDataSourceApi = (data: DataSourceUpdateDTO) => {
    return request({
        url: `${commonUrl}/updateDataSource`, // 假设创建模板的API路径
        method: 'put',
        data // 将数据传递到请求体中
    })
}

//数据源分页
export const pageDataSourceApi = (params: DataSourceQuery) => {
    return request({
        url: `${commonUrl}/pageDataSource`,
        method: 'get',
        params: params
    })
}

//数据源列表
export const listDataSourceApi = (params: DataSourceQuery) => {
    return request({
        url: `${commonUrl}/listDataSource`,
        method: 'get',
        params: params
    })
}

//数据源详情
export const getOneDataSourceApi = (id: string) => {
    return request({
        url: `${commonUrl}/getOneDataSource`,
        method: 'get',
        params: {id}
    })
}

//数据源内容详情
export const getDataSourceByIdApi = (id: string) => {
    return request({
        url: `${commonUrl}/getDataSourceById`,
        method: 'get',
        params: {id}
    })
}

//删除数据源
export const deleteDataSourceApi = (id: string) => {
    return request({
        url: `${commonUrl}/deleteDataSource`,
        method: 'delete',
        params: {id}
    })
}

//获取数据源枚举
export const getEnumDataSourceApi = () => {
    return request({
        url: `${commonUrl}/getEnumDataSource`,
        method: 'get'
    })
}

//验证数据源
export const dataVerificationApi = (data: DataSourceAddDTO) => {
    return request({
        url: `${commonUrl}/dataVerification`, // 假设创建模板的API路径
        method: 'post',
        data // 将数据传递到请求体中
    })
}

//获取支持类型
export const getSupportTypeApi = () => {
    return request({
        url: `${commonUrl}/getSupportType`, // 假设创建模板的API路径
        method: 'get',
    })
}
